package inputStreamReader;

import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.nio.charset.Charset;

public class Demo2 {
    public static void main(String[] args) throws IOException {
        //将GBK编码的文件转写成UTF-8的并另存
        //采用jdk11以后的方式
        FileReader fr = new FileReader("IODemo\\gbkfile.txt", Charset.forName("GBK"));
        FileWriter fw = new FileWriter("IODemo\\utf-8.txt",Charset.forName("UTF-8"));
        int b;
        while((b = fr.read()) != -1){
            fw.write(b);
        }
        //释放资源
        fw.close();
        fr.close();
    }
}
